using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Preparation;
using Tester.Forms;

namespace Tester.GuiActions.Actions.Impl
{
    public class RemoveAction :BaseAction
    {
        public override bool Visible
        {
            get
            {
                return
                    TesterMultyDocument.Instance != null && 
                    TesterMultyDocument.Instance.Suspended == TesterMultyDocument.SuspendStates.Stopped&&
                    (TesterList.Instance != null &&  TesterList.Instance.SelectedItems.Count > 0) &&
                    HasWhiteSelected() &&
                    TesterMainForm.Instance.TopControl == EmbededControlTags.TesterList;
            }
        }

        private static bool HasWhiteSelected()
        {
            bool hasWhiteSelected = false;
            foreach (ListViewItem item in TesterList.Instance.SelectedItems)
            {
                if (item.Tag != null)
                {
                    hasWhiteSelected = true;
                    break; 
                }
            }
            return hasWhiteSelected;
        }

        public override void MainAction(object sender, EventArgs e)
        {
            if (Visible)
            {
                TesterList.Instance.RemoveSelectedTest();
            }
        }
    }
}



